import Vue from 'vue'
import Router from 'vue-router'
import Generator from './views/generator/Generator'
import GeneratorConfig from './views/generator/GeneratorConfig'
import Dashboard from './views/dashboard/Dashboard'

const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}

Vue.use(Router)

const router = new Router({
  mode: 'history',
  routes: [

    // {
    //   path: '/home',
    //   component: Home,
    //   redirect: '/welcome',
    //   children: [
    //     { path: '/welcome', component: Welcome },
    //     { path: '/users', component: Users },
    //     { path: '/permissions', component: Permissions },
    //     { path: '/roles', component: Roles },
    //     { path: '/categories', component: Cate },
    //     { path: '/params', component: Params },
    //     { path: '/list', component: List },
    //     { path: '/add/goods', component: GoodsAdd },
    //   ]
    // }
  ]
})

// 挂载路有导航守卫

router.beforeEach((to, from, next) => {
  // to 将要访问的路径
  // from 从哪个页面来
  // next 放行函数
  // if (to.path == "/login") return next();
  // //获取token
  // const tokenStr = window.sessionStorage.getItem("token");
  // if (!tokenStr) return next("/login");
  return next()
})

export default router
